/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package baiwa.rta.service.Impl;

import baiwa.rta.dao.CarCardDao;
import baiwa.rta.dao.TowersDao;
import baiwa.rta.model.DataTableModel;
import baiwa.rta.model.RMaccrModel;
import baiwa.rta.model.TowerModel;
import baiwa.rta.service.CarCardService;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author jirapatjantsakool
 */
@Service("CarCardService")
public class CarCardServiceImpl implements CarCardService {

	@Autowired
	CarCardDao dao;

	@Autowired
	private TowersDao towersDao;

	@Override
	public List<RMaccrModel> getAllCarCard() {
		return dao.findAll();
	}

	@Override
	public RMaccrModel getCarCardById(Integer accrid) {
		return dao.findById(accrid);
	}

	@Override
	@Transactional
	public void save(RMaccrModel model) throws Exception {
		dao.create(model);
	}

	@Override
	@Transactional
	public boolean update(RMaccrModel model) {
		return dao.update(model);
	}

	@Override
	@Transactional
	public boolean delete(RMaccrModel model) {
		return dao.delete(model);
	}

	@Deprecated
	@Override
	public List<Map<String, Object>> getAllMapCarCard() {
		return dao.findAllMap();
	}

	@Override
	public TowerModel findRoomId(TowerModel towerModel) {
		return towersDao.findTowerByAddress(towerModel);
	}

	@Override
	public int nextCarCardId() {
		return dao.nextCarCardId();
	}

	@Override
	public DataTableModel<RMaccrModel> getDataTable(RMaccrModel model,
			int iDisplayStart, int iDisplayLength) {
		return dao.findDataTable(model, iDisplayStart, iDisplayLength);
	}

}
